package com.gsafety.wellsfort.controller.course;

import com.gsafety.wellsfort.common.util.ApiResponse;
import com.gsafety.wellsfort.domain.dto.course.*;
import com.gsafety.wellsfort.domain.dto.ids.ExamPublishIdDTO;
import com.gsafety.wellsfort.domain.dto.ids.WorkPublishIdDTO;
import com.gsafety.wellsfort.domain.vo.*;
import com.gsafety.wellsfort.service.course.ExamPublishService;
import com.gsafety.wellsfort.service.course.WorkPublishService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(value = "试卷发布及发布记录管理",description = "试卷发布及发布记录管理接口")
@RestController
@Slf4j
@RequestMapping("/api/empublish")
public class ExamPublishController {
    @Autowired
    ExamPublishService examPublishService;
    @ApiOperation(value="发布试卷")
    @PostMapping("/publish-stuExam")
    public ApiResponse<ExamPublishDTO> publishStuExam(@RequestBody ExamPublishDTO examPublishDTO){
        return examPublishService.publishStuExam(examPublishDTO);
    }

    @ApiOperation(value="分页查询发布试卷记录")
    @PostMapping("/list")
    public ApiResponse<List<ExamPublishVO>> listPublicWork(@RequestBody ExamPublishQueryDTO examPublishQueryDTO){

        return examPublishService.listPublishExam(examPublishQueryDTO);
    }

    @ApiOperation(value="编辑或预览发布试卷记录")
    @PostMapping("/detail")
    public ApiResponse<ExamPublishEditVO> getPublicWorkDetail(@RequestBody ExamPublishIdDTO examPublishIdDTO){
        return examPublishService.getPublicExamDetail(examPublishIdDTO);
    }

    @ApiOperation(value="取消发布试卷")
    @PostMapping("/cancel")
    public ApiResponse cancelWorkPublish(@RequestBody ExamPublishIdDTO examPublishIdDTO){

        return examPublishService.cancelExamPublish(examPublishIdDTO);
    }

    @ApiOperation(value="再次发布试卷")
    @PostMapping("/agin-publish")
    public ApiResponse againWorkPublish(@RequestBody ExamPublishIdDTO examPublishIdDTO){

        return examPublishService.againEaxamPublish(examPublishIdDTO);
    }

    @ApiOperation(value="完成预览")
    @PostMapping("/finish-preview")
    public ApiResponse<ExamFinishPreviewVO> finishPreview(@RequestBody ExamFinishPreviewDTO examFinishPreviewDTO){

        return examPublishService.finishPreview(examFinishPreviewDTO);
    }
}
